home *** CD-ROM | disk | FTP | other *** search
/ Run Magazine ReRun: Super Starter Pak 2 / rerun-super-starter-pak-ii-1991-side-b.d64 / define macros (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  2KB  |  82 lines

  1. 10 rem define macros by robert rockefeller
  2. 20 print"[147]             define macros ":print
  3. 30 print
  4. 40 print"   refer to the documentation for the "
  5. 50 print"   instructions for using this program."
  6. 60 print:print"         press any key to continue"
  7. 70 geta$:if a$=""then 70
  8. 90 dim flag%(51) : rem flag array indicates if a certain macro is defined
  9. 100 dim macro$(51) : rem holds macro strings
  10. 110 m1$="this character has been used. would you like to select another (y/n)?"
  11. 120 m2$="how many characters will be in the"
  12. 130 m2$=m2$+"      macro string represented by this        character ? "
  13. 140 a=780 : x=781 : y=782 : rem sys registers
  14. 180 rem select macro character
  15. 200 print"[147]select a macro character."
  16. 210 gosub 1130
  17. 230 if a$<>"*" then 300
  18. 240 print"which macro definition do you wish to   cancel ?"
  19. 250 gosub 1130
  20. 260 if a$="*" then 240
  21. 270 flag%(macnum)=0 : rem cancel def
  22. 280 goto 470
  23. 300 if flag%(macnum)<>0 then print m1$ : input b$ : if left$(b$,1)="y" then 200
  24. 320 flag%(macnum)=1
  25. 330 macro$(macnum)=""
  26. 370 rem define macro string
  27. 390 printm2$: input count
  28. 400 if count>20 then 390
  29. 420 for loop=1 to count
  30. 430 input"decimal value ";dec
  31. 440 macro$(macnum)=macro$(macnum)+chr$(dec)
  32. 450 next loop
  33. 470 input"finished all definitions (y/n) ";b$
  34. 480 if left$(b$,1)<>"y" then 200
  35. 520 rem create macro table
  36. 540 ptr=4*4096 : rem create macro table at this address
  37. 550 for entry=0 to 51
  38. 560 if flag%(entry)=0 then 750
  39. 580 rem convert to reversed screen code value
  40. 590 if entry<26 then code=entry+1+128
  41. 600 if entry>25 then code= entry+39+128
  42. 620 poke ptr,code : rem 1st byte of 1 macro entry is screen code value
  43. 630 ptr=ptr+1 : rem next table byte
  44. 650 poke ptr,len(macro$(entry))+2 : rem 2nd byte is entry length
  45. 660 ptr=ptr+1 : rem next table byte
  46. 680 for iloop=1 to len(macro$(entry)) : rem rest of 1 entry is macro string
  47. 690 poke ptr,asc(mid$(macro$(entry),iloop,1))
  48. 700 ptr=ptr+1
  49. 710 next iloop
  50. 730 if ptr=>4*4096+500 then print"macro table too large !!!" : stop
  51. 750 next entry
  52. 790 rem save macro table
  53. 820 print"[147]8 - disk
  54. 830 [153]"9 - disk
  55. 840 input"save to device number ";dev
  56. 850 if dev<>1 and dev<>8 and dev<>9 then 840
  57. 870 rem use the kernal setlfs
  58. 880 poke a,0 : poke x,dev : poke y,0
  59. 890 sys 65466
  60. 910 rem setup filename
  61. 920 b$="runscript macros"
  62. 930 for loop=1 to len(b$)
  63. 940 poke 849+loop,asc(mid$(b$,loop,1))
  64. 950 next loop
  65. 970 rem use kernal setnam
  66. 980 poke a,len(b$) : poke x,850and255 : poke y,850/256
  67. 990 sys 65469
  68. 1010 rem use kernal save
  69. 1020 poke 253,0 : poke 254,4*16
  70. 1030 poke a,253 : poke x,ptrand255 : poke y,ptr/256
  71. 1040 sys 65496
  72. 1070 end
  73. 1110 rem input subroutine
  74. 1130 input a$ : a$=left$(a$,1)
  75. 1150 if a$="*" then return
  76. 1160 if a$<"a" then 1130
  77. 1170 if a$>"[218]" then 1130
  78. 1180 if a$>"z" and a$<"[193]" then 1130
  79. 1200 if a$<="z" then macnum=asc(a$)-65
  80. 1210 if a$>="[193]" then macnum=asc(a$)-167
  81. 1230 return
  82.